package com.lc.rongzecaifu.adapter;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.lc.rongzecaifu.activity.BaseActivity;
import com.lc.rongzecaifu.rongzecaifu.R;
import com.zcx.helper.bound.BoundView;
import com.zcx.helper.util.UtilToast;

/**
 * Created by Administrator on 2017/3/27.
 */
public class WithDrawWebActivity extends   BaseActivity implements View.OnClickListener{


    @BoundView(R.id.regist_web_title_rl) private RelativeLayout regist_web_title_rl;//title  默认隐藏
    @BoundView(R.id.regist_web_wv) private WebView regist_web_wv;

    private TextView tv_title;

    @SuppressLint("JavascriptInterface")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_withdraw_web);
        tv_title= (TextView) findViewById(R.id.tv_title);
        // 支持js
        regist_web_wv.getSettings().setJavaScriptEnabled(true);
        regist_web_wv.setWebChromeClient(new WebChromeClient());
        regist_web_wv.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);

        // 缩放
        regist_web_wv.getSettings().setSupportZoom(true);
        regist_web_wv.getSettings().setBuiltInZoomControls(false);

        regist_web_wv.addJavascriptInterface(this, "android");

        regist_web_wv.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageFinished(WebView view, String url) {

                regist_web_wv.loadUrl("javascript:getvalue()");

                super.onPageFinished(view, url);
            }

        });

        String url = getIntent().getStringExtra("url");

        if (!TextUtils.isEmpty(url)) {

            regist_web_wv.loadUrl(url);

        } else {

            UtilToast.show(context, "注册时候返回的url没传过来  或者 根本没返回url");
        }



    }



    @Override
    public void onClick(View view) {
        super.onClick(view);
        switch (view.getId()){
            case R.id.tv_title:
                finish();
                break;
        }
    }

}
